package com.jumi.microservice.stock.controller;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.material.service.JmMaterialService;
import com.jumi.microservice.stock.domain.StockCheckLogVO;
import com.jumi.microservice.stock.dto.StockLogResponse;
import com.jumi.microservice.stock.dto.StockLogSearchRequest;
import com.jumi.microservice.stock.service.StockCheckLogService;
import com.jumi.microservice.stock.service.StockLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName JmStockLogController
 * @Description
 * @Author Abel Yang
 * @Date 2020/8/24/024 13:29
 **/
@RestController
@RequestMapping("/supply/stock/log")
@Api(tags = {"【仓库管理】库存日志管理接口"})
public class StockLogController extends BaseController {

    @Resource
    private StockLogService jmStockLogService;

    @Resource
    private JmMaterialService jmMaterialService;

    @Resource
    private StockCheckLogService stockCheckLogService;

    /**
     * @return
     * @Description:
     * @Param jmStockLogSearchRequest
     * @Return {@link TableDataInfo<  StockLogResponse >}
     * @Throws
     * @Author Abel Yang
     * @Date 2020/8/24/024 16:30
     */
    @PostMapping("/getListByPage")
    @ApiOperation("分页查询库存日志分页列表")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"),
                    @ApiImplicitParam(name = "warehouseId", value = "仓库id", dataType = "Long", paramType = "query"),
                    @ApiImplicitParam(name = "materialId", value = "物料id", dataType = "Long", paramType = "query"),
                    @ApiImplicitParam(name = "changeType", value = "变动类型", dataType = "Integer", paramType = "query"),
                    @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query"),
                    @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query"),
                    @ApiImplicitParam(name = "logTypes", value = "日志类型：0常规，1：占用，2破损", dataType = "String", paramType = "query"),

            })
    public TableDataInfo<List<StockLogResponse>> getStockLogListByPage(StockLogSearchRequest jmStockLogSearchRequest) {
        startPage();
        List<StockLogResponse> stockLogList = jmStockLogService.getStockLogList(jmStockLogSearchRequest);
        return getDataTable(stockLogList);
    }

    /**
     * @Description: 查询审核日志列表
     * @Param checkType
     * @Param applyId
     * @Return {@link TableDataInfo< List< StockCheckLogVO>>}
     * @Throws
     * @Author Abel Yang
     * @Date 2020/9/18/018 17:45
     */
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "checkType", value = "审核类型:1-仓库间调拨,2-仓库内调货", dataType = "java.lang.Byte"),
            @ApiImplicitParam(name = "applyId", value = "申请id", dataType = "java.lang.Long")})
    @ApiOperation("分页查询库存审核日志列表")
    @GetMapping("/getCheckLogListByPage")
    public TableDataInfo<List<StockCheckLogVO>> getCheckLogList(Byte checkType, Long applyId) {
        startPage();
        List<StockCheckLogVO> list = stockCheckLogService.getList(checkType, applyId);
        return getDataTable(list);
    }
}
